home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-11 | 15.9 KB | 696 lines | [TEXT/MPS ] |
- ;
- ; File: Sound.a
- ;
- ; Copyright: © 1984-1994 by Apple Computer, Inc.
- ; All rights reserved.
- ;
- ; Version: Universal Interfaces 2.0a3 ETO #16, MPW prerelease. Friday, November 11, 1994.
- ;
- ; Bugs?: If you find a problem with this file, send the file and version
- ; information (from above) and the problem description to:
- ;
- ; Internet: apple.bugs@applelink.apple.com
- ; AppleLink: APPLE.BUGS
- ;
- ;
-
- IF &TYPE('__SOUND__') = 'UNDEFINED' THEN
- __SOUND__ SET 1
-
-
- IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
- include 'Types.a'
- ENDIF
- ; include 'ConditionalMacros.a' ;
-
- IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
- include 'MixedMode.a'
- ENDIF
- ;
- ;Interface for Sound Driver, !!! OBSOLETE and NOT SUPPORTED !!!
- ;
- ;These items are no longer defined, but appear here so that someone
- ;searching the interfaces might find them. If you are using one of these
- ;items, you must change your code to support the Sound Manager.
- ;
- ; swMode, ftMode, ffMode
- ; FreeWave, FFSynthRec, Tone, SWSynthRec, Wave, FTSoundRec
- ; SndCompletionProcPtr
- ; StartSound, StopSound, SoundDone
- ;
-
- soundListRsrc EQU 'snd ' ;Resource type used by Sound Manager
- rate44khz EQU $AC440000 ;44100.00000 in fixed-point
- rate22050hz EQU $56220000 ;22050.00000 in fixed-point
- rate22khz EQU $56EE8BA3 ;22254.54545 in fixed-point
- rate11khz EQU $2B7745D1 ;11127.27273 in fixed-point
- rate11025hz EQU $2B110000 ;11025.00000 in fixed-point
- ;synthesizer numbers for SndNewChannel
- squareWaveSynth EQU 1 ;square wave synthesizer
- waveTableSynth EQU 3 ;wave table synthesizer
- sampledSynth EQU 5 ;sampled sound synthesizer
- ;old Sound Manager MACE synthesizer numbers
- MACE3snthID EQU 11
- MACE6snthID EQU 13
- kMiddleC EQU 60 ;MIDI note value for middle C
- kSimpleBeepID EQU 1 ;reserved resource ID for Simple Beep
- kFullVolume EQU $0100 ;1.0, setting for full hardware output volume
- kNoVolume EQU 0 ;setting for no sound volume
- ;command numbers for SndDoCommand and SndDoImmediate
- nullCmd EQU 0
- initCmd EQU 1
- freeCmd EQU 2
- quietCmd EQU 3
- flushCmd EQU 4
- reInitCmd EQU 5
- waitCmd EQU 10
- pauseCmd EQU 11
- resumeCmd EQU 12
- callBackCmd EQU 13
-
- syncCmd EQU 14
- availableCmd EQU 24
- versionCmd EQU 25
- totalLoadCmd EQU 26
- loadCmd EQU 27
- freqDurationCmd EQU 40
- restCmd EQU 41
- freqCmd EQU 42
- ampCmd EQU 43
- timbreCmd EQU 44
- getAmpCmd EQU 45
- volumeCmd EQU 46 ;sound manager 3.0 or later only
- getVolumeCmd EQU 47 ;sound manager 3.0 or later only
- waveTableCmd EQU 60
- phaseCmd EQU 61
-
- soundCmd EQU 80
- bufferCmd EQU 81
- rateCmd EQU 82
- continueCmd EQU 83
- doubleBufferCmd EQU 84
- getRateCmd EQU 85
- rateMultiplierCmd EQU 86
- getRateMultiplierCmd EQU 87
- sizeCmd EQU 90
- convertCmd EQU 91
- stdQLength EQU 128
- dataOffsetFlag EQU $8000
-
- ;channel initialization parameters
- IF OLDROUTINENAMES THEN
- waveInitChannelMask EQU $07
- waveInitChannel0 EQU $04 ;wave table only, Sound Manager 2.0 and earlier
- waveInitChannel1 EQU $05 ;wave table only, Sound Manager 2.0 and earlier
- waveInitChannel2 EQU $06 ;wave table only, Sound Manager 2.0 and earlier
- waveInitChannel3 EQU $07 ;wave table only, Sound Manager 2.0 and earlier
- initChan0 EQU waveInitChannel0 ;obsolete spelling
- initChan1 EQU waveInitChannel1 ;obsolete spelling
- initChan2 EQU waveInitChannel2 ;obsolete spelling
- initChan3 EQU waveInitChannel3 ;obsolete spelling
-
- ENDIF
- initChanLeft EQU $0002 ;left stereo channel
- initChanRight EQU $0003 ;right stereo channel
- initNoInterp EQU $0004 ;no linear interpolation
- initNoDrop EQU $0008 ;no drop-sample conversion
- initMono EQU $0080 ;monophonic channel
- initStereo EQU $00C0 ;stereo channel
- initMACE3 EQU $0300 ;MACE 3:1
- initMACE6 EQU $0400 ;MACE 6:1
- initPanMask EQU $0003 ;mask for right/left pan values
- initSRateMask EQU $0030 ;mask for sample rate values
- initStereoMask EQU $00C0 ;mask for mono/stereo values
- initCompMask EQU $FF00 ;mask for compression IDs
- kUseOptionalOutputDevice EQU -1 ;only for Sound Manager 3.0 or later
- notCompressed EQU 0 ;compression ID's
- fixedCompression EQU -1 ;compression ID for fixed-sized compression
- variableCompression EQU -2 ;compression ID for variable-sized compression
- twoToOne EQU 1
- eightToThree EQU 2
- threeToOne EQU 3
- sixToOne EQU 4
-
- outsideCmpSH EQU 0 ;MACE constants
- insideCmpSH EQU 1
- aceSuccess EQU 0
- aceMemFull EQU 1
- aceNilBlock EQU 2
- aceBadComp EQU 3
- aceBadEncode EQU 4
- aceBadDest EQU 5
- aceBadCmd EQU 6
- sixToOnePacketSize EQU 8
- threeToOnePacketSize EQU 16
- stateBlockSize EQU 64
- leftOverBlockSize EQU 32
- firstSoundFormat EQU $0001 ;general sound format
- secondSoundFormat EQU $0002 ;special sampled sound format (HyperCard)
- dbBufferReady EQU $00000001 ;double buffer is filled
- dbLastBuffer EQU $00000004 ;last double buffer to play
- sysBeepDisable EQU $0000 ;SysBeep() enable flags
- sysBeepEnable EQU $0001
- unitTypeNoSelection EQU $FFFF ;unitTypes for AudioSelection.unitType
- unitTypeSeconds EQU $0000
-
- ; unsigned fixed-point number
- SndCommand RECORD 0
- cmd ds.w 1
- param1 ds.w 1
- param2 ds.l 1
- sizeof EQU 8
- ENDR
-
- SndChannel RECORD 0
- nextChan ds.l 1
- firstMod ds.l 1 ; reserved for the Sound Manager
- callBack ds.l 1
- userInfo ds.l 1
- wait ds.l 1 ; The following is for internal Sound Manager use only.
- cmdInProgress ds SndCommand
- flags ds.w 1
- qLength ds.w 1
- qHead ds.w 1
- qTail ds.w 1
- queue ds SndCommand
- sizeof EQU 44
- ENDR
-
- ;MACE structures
- StateBlock RECORD 0
- stateVar ds.w 1
- sizeof EQU 2
- ENDR
-
- LeftOverBlock RECORD 0
- count ds.l 1
- sampleArea ds.b 1
- sizeof EQU 6
- ENDR
-
- ModRef RECORD 0
- modNumber ds.w 1
- modInit ds.l 1
- sizeof EQU 6
- ENDR
-
- SndListResource RECORD 0
- format ds.w 1
- numModifiers ds.w 1
- modifierPart ds ModRef ;This is a variable length array
- numCommands ds.w 1
- commandPart ds SndCommand ;This is a variable length array
- dataPart ds.b 1 ;This is a variable length array
- sizeof EQU 22
- ENDR
-
- ;HyperCard sound resource format
- Snd2ListResource RECORD 0
- format ds.w 1
- refCount ds.w 1
- numCommands ds.w 1
- commandPart ds SndCommand ;This is a variable length array
- dataPart ds.b 1 ;This is a variable length array
- sizeof EQU 16
- ENDR
-
- SoundHeader RECORD 0
- samplePtr ds.l 1 ;if NIL then samples are in sampleArea
- length ds.l 1 ;length of sound in bytes
- sampleRate ds.l 1 ;sample rate for this sound
- loopStart ds.l 1 ;start of looping portion
- loopEnd ds.l 1 ;end of looping portion
- encode ds.b 1 ;header encoding
- baseFrequency ds.b 1 ;baseFrequency value
- sampleArea ds.b 1 ;space for when samples follow directly
- sizeof EQU 24
- ENDR
-
- CmpSoundHeader RECORD 0
- samplePtr ds.l 1 ;if nil then samples are in sample area
- numChannels ds.l 1 ;number of channels i.e. mono = 1
- sampleRate ds.l 1 ;sample rate in Apples Fixed point representation
- loopStart ds.l 1 ;loopStart of sound before compression
- loopEnd ds.l 1 ;loopEnd of sound before compression
- encode ds.b 1 ;data structure used , stdSH, extSH, or cmpSH
- baseFrequency ds.b 1 ;same meaning as regular SoundHeader
- numFrames ds.l 1 ;length in frames ( packetFrames or sampleFrames )
- AIFFSampleRate ds.w 5 ;IEEE sample rate
- markerChunk ds.l 1 ;sync track
- format ds.l 1 ;data format type, was futureUse1
- futureUse2 ds.l 1 ;reserved by Apple
- stateVars ds.l 1 ;pointer to State Block
- leftOverSamples ds.l 1 ;used to save truncated samples between compression calls
- compressionID ds.w 1 ;0 means no compression, non zero means compressionID
- packetSize ds.w 1 ;number of bits in compressed sample packet
- snthID ds.w 1 ;resource ID of Sound Manager snth that contains NRT C/E
- sampleSize ds.w 1 ;number of bits in non-compressed sample
- sampleArea ds.b 1 ;space for when samples follow directly
- sizeof EQU 66
- ENDR
-
- ExtSoundHeader RECORD 0
- samplePtr ds.l 1 ;if nil then samples are in sample area
- numChannels ds.l 1 ;number of channels, ie mono = 1
- sampleRate ds.l 1 ;sample rate in Apples Fixed point representation
- loopStart ds.l 1 ;same meaning as regular SoundHeader
- loopEnd ds.l 1 ;same meaning as regular SoundHeader
- encode ds.b 1 ;data structure used , stdSH, extSH, or cmpSH
- baseFrequency ds.b 1 ;same meaning as regular SoundHeader
- numFrames ds.l 1 ;length in total number of frames
- AIFFSampleRate ds.w 5 ;IEEE sample rate
- markerChunk ds.l 1 ;sync track
- instrumentChunks ds.l 1 ;AIFF instrument chunks
- AESRecording ds.l 1
- sampleSize ds.w 1 ;number of bits in sample
- futureUse1 ds.w 1 ;reserved by Apple
- futureUse2 ds.l 1 ;reserved by Apple
- futureUse3 ds.l 1 ;reserved by Apple
- futureUse4 ds.l 1 ;reserved by Apple
- sampleArea ds.b 1 ;space for when samples follow directly
- sizeof EQU 66
- ENDR
-
- ConversionBlock RECORD 0
- destination ds.w 1
- unused ds.w 1
- inputPtr ds.l 1
- outputPtr ds.l 1
- sizeof EQU 12
- ENDR
-
- SMStatus RECORD 0
- smMaxCPULoad ds.w 1
- smNumChannels ds.w 1
- smCurCPULoad ds.w 1
- sizeof EQU 6
- ENDR
-
- SCStatus RECORD 0
- scStartTime ds.l 1
- scEndTime ds.l 1
- scCurrentTime ds.l 1
- scChannelBusy ds.b 1
- scChannelDisposed ds.b 1
- scChannelPaused ds.b 1
- scUnused ds.b 1
- scChannelAttributes ds.l 1
- scCPULoad ds.l 1
- sizeof EQU 24
- ENDR
-
- AudioSelection RECORD 0
- unitType ds.l 1
- selStart ds.l 1
- selEnd ds.l 1
- sizeof EQU 12
- ENDR
-
- SndDoubleBuffer RECORD 0
- dbNumFrames ds.l 1
- dbFlags ds.l 1
- dbUserInfo ds.l 2
- dbSoundData ds.b 1
- sizeof EQU 18
- ENDR
-
- SndDoubleBufferHeader RECORD 0
- dbhNumChannels ds.w 1
- dbhSampleSize ds.w 1
- dbhCompressionID ds.w 1
- dbhPacketSize ds.w 1
- dbhSampleRate ds.l 1
- dbhBufferPtr ds.l 2
- dbhDoubleBack ds.l 1
- sizeof EQU 24
- ENDR
-
- SndDoubleBufferHeader2 RECORD 0
- dbhNumChannels ds.w 1
- dbhSampleSize ds.w 1
- dbhCompressionID ds.w 1
- dbhPacketSize ds.w 1
- dbhSampleRate ds.l 1
- dbhBufferPtr ds.l 2
- dbhDoubleBack ds.l 1
- dbhFormat ds.l 1
- sizeof EQU 28
- ENDR
-
- SoundInfoList RECORD 0
- count ds.w 1
- infoHandle ds.l 1
- sizeof EQU 6
- ENDR
-
- CompressionInfo RECORD 0
- recordSize ds.l 1
- format ds.l 1
- compressionID ds.w 1
- samplesPerPacket ds.w 1
- bytesPerPacket ds.w 1
- bytesPerFrame ds.w 1
- bytesPerSample ds.w 1
- futureUse1 ds.w 1
- sizeof EQU 20
- ENDR
-
- ; These two routines for Get/SetSoundVol should no longer be used.
- ; They were for old Apple Sound Chip machines, and do not support the DSP or PowerMacs.
- ; Use Get/SetDefaultOutputVolume instead, if you must change the user's machine.
- IF OLDROUTINENAMES ** ¬ GENERATINGCFM THEN
- IF GENERATING68K THEN
- Macro
- _GetSoundVol
- dc.w $4218
- dc.w $10B8
- dc.w $0260
- EndM
- ELSE
- IMPORT GetSoundVol
- ENDIF
-
- ENDIF
- IF GENERATING68K THEN
- _SndDoCommand: OPWORD $A803
- ELSE
- IMPORT SndDoCommand
- ENDIF
-
- IF GENERATING68K THEN
- _SndDoImmediate: OPWORD $A804
- ELSE
- IMPORT SndDoImmediate
- ENDIF
-
- IF GENERATING68K THEN
- _SndNewChannel: OPWORD $A807
- ELSE
- IMPORT SndNewChannel
- ENDIF
-
- IF GENERATING68K THEN
- _SndDisposeChannel: OPWORD $A801
- ELSE
- IMPORT SndDisposeChannel
- ENDIF
-
- IF GENERATING68K THEN
- _SndPlay: OPWORD $A805
- ELSE
- IMPORT SndPlay
- ENDIF
-
- IF GENERATING68K THEN
- _SndAddModifier: OPWORD $A802
- ELSE
- IMPORT SndAddModifier
- ENDIF
-
- IF GENERATING68K THEN
- _SndControl: OPWORD $A806
- ELSE
- IMPORT SndControl
- ENDIF
-
- ; Sound Manager 2.0 and later, uses _SoundDispatch
- IF GENERATING68K THEN
- Macro
- _SndSoundManagerVersion
- dc.w $203C
- dc.w $000C
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndSoundManagerVersion
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SndStartFilePlay
- dc.w $203C
- dc.w $0D00
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndStartFilePlay
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SndPauseFilePlay
- dc.w $203C
- dc.w $0204
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndPauseFilePlay
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SndStopFilePlay
- dc.w $203C
- dc.w $0308
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndStopFilePlay
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SndChannelStatus
- dc.w $203C
- dc.w $0010
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndChannelStatus
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SndManagerStatus
- dc.w $203C
- dc.w $0014
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndManagerStatus
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SndGetSysBeepState
- dc.w $203C
- dc.w $0018
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndGetSysBeepState
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SndSetSysBeepState
- dc.w $203C
- dc.w $001C
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndSetSysBeepState
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SndPlayDoubleBuffer
- dc.w $203C
- dc.w $0020
- dc.w $0008
- dc.w $A800
- EndM
- ELSE
- IMPORT SndPlayDoubleBuffer
- ENDIF
-
- ; MACE compression routines
- IF GENERATING68K THEN
- Macro
- _MACEVersion
- dc.w $203C
- dc.w $0000
- dc.w $0010
- dc.w $A800
- EndM
- ELSE
- IMPORT MACEVersion
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _Comp3to1
- dc.w $203C
- dc.w $0004
- dc.w $0010
- dc.w $A800
- EndM
- ELSE
- IMPORT Comp3to1
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _Exp1to3
- dc.w $203C
- dc.w $0008
- dc.w $0010
- dc.w $A800
- EndM
- ELSE
- IMPORT Exp1to3
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _Comp6to1
- dc.w $203C
- dc.w $000C
- dc.w $0010
- dc.w $A800
- EndM
- ELSE
- IMPORT Comp6to1
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _Exp1to6
- dc.w $203C
- dc.w $0010
- dc.w $0010
- dc.w $A800
- EndM
- ELSE
- IMPORT Exp1to6
- ENDIF
-
- ; Sound Manager 3.0 and later calls
- IF GENERATING68K THEN
- Macro
- _GetSysBeepVolume
- dc.w $203C
- dc.w $0224
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT GetSysBeepVolume
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SetSysBeepVolume
- dc.w $203C
- dc.w $0228
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT SetSysBeepVolume
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _GetDefaultOutputVolume
- dc.w $203C
- dc.w $022C
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT GetDefaultOutputVolume
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SetDefaultOutputVolume
- dc.w $203C
- dc.w $0230
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT SetDefaultOutputVolume
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _GetSoundHeaderOffset
- dc.w $203C
- dc.w $0404
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT GetSoundHeaderOffset
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _UnsignedFixedMulDiv
- dc.w $203C
- dc.w $060C
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT UnsignedFixedMulDiv
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _GetCompressionInfo
- dc.w $203C
- dc.w $0710
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT GetCompressionInfo
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _SetSoundPreference
- dc.w $203C
- dc.w $0634
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT SetSoundPreference
- ENDIF
-
- IF GENERATING68K THEN
- Macro
- _GetSoundPreference
- dc.w $203C
- dc.w $0638
- dc.w $0018
- dc.w $A800
- EndM
- ELSE
- IMPORT GetSoundPreference
- ENDIF
-
- ENDIF ; __SOUND__
-